<?php
namespace Modules\User\Entities;

use Modules\Core\Entities\BaseEntity as Model;
use Modules\User\Entities\User;

use ThrowException;

// 人群价
class UserGroupPrice extends Model
{
    protected $guarded = [];
    protected $table = 'user_group_price';

    protected $casts = [
    ];

    static public $resourceName = '分组价';

    public function group()
    {
        return $this->belongsTo('\Modules\User\Entities\UserGroup', 'group_id');
    }

    // 对某个sku是否有效
    public function isUsableForSku($sku)
    {
    	if ($this->target_type === 'product') {
	        return @$this->target_id === $sku->parent_product->id;
    	}

    	return false;
    }
}
